//
//  AppDelegate.m
//  UI_07_UITabBarController
//
//  Created by li cheng on 16/7/22.
//  Copyright © 2016年 li cheng. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] init];
    _window.backgroundColor = [UIColor whiteColor];
    [_window makeKeyAndVisible];
    ViewController *vc = [[ViewController alloc] init];
//    vc.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人中心" image:nil tag:100];
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:vc];
    navigation.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人中心" image:nil tag:100];
    // UITabBarController 标签视图控制
    // 主要管理,没有层级关系车视图
    // 1.viewControllers 所有被管理的视图控制器,都在这个数组中,
    // 可以通过setter方法的形式, 去赋值
    // 2.setViewControllerers:animated:
    // 3. 通过一个数组创建完成后,如果数组中的控制没有设置
    // tabBarItem, 只显示一个空的tabBatItem
    // 4.tabBarItem 根据自己需求要求创建对应的tabBarItem
    // UIViewController的属性(Category)
    // 因为: 每个视图控制器的tabBarItem都不一样,因此不嗯呢设为TabBarController的属性
    // 创建方式
    // 1> initWithTabBatSystemItem:tag: 根据系统样式创建
    // 2> initWithTitle:image:tag 根据自定义的图片和文字创建
    // 3> initWithTitle:image:selectedImage:tag 根据自定义的图片和文字创建,增添选中的图片
    // 5. 如果数组个数过多(对于5个), 系统会把多余的部分做列表来管理,不要大于5个
    // 6.tabBar
    //  1> barTintColor bar的背景色
    //  2> tintColor bar上元素的颜色
    //  3> translucent bar是否透明(默认是YES, 半透明)
    
    
    UITabBarController *tabBar = [[UITabBarController alloc] init];
    // 高度 49
    tabBar.tabBar.tintColor = [UIColor greenColor];
    tabBar.tabBar.translucent = NO;
    UIViewController * vc1 = [[UIViewController alloc] init];
    vc1.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"新闻" image:nil tag:200];
    vc1.tabBarItem.badgeValue = @"来打我";
    UIViewController * vc2 = [[UIViewController alloc] init];
    vc2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"视频" image:nil tag:300];
    UIViewController * vc3 = [[UIViewController alloc] init];
    vc3.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"电影" image:nil tag:400];
    UIViewController * vc4 = [[UIViewController alloc] init];
    vc4.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"音乐" image:nil tag:500];
    // 设置tabBarItem时, 给你要放进的数组中的控制器去设置
    NSArray *array = @[navigation, vc1, vc2, vc3, vc4];
    [tabBar setViewControllers:array animated:YES];
    // 7. UIAppearance 全局设置
    [[UITabBar appearance] setTintColor:[UIColor yellowColor]];
    [[UITabBar appearance] setBarTintColor:[UIColor lightGrayColor]];
    
    [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
    // 修改系统标题的颜色
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
    // VC中self.title 与 self.navigationItem.title 有区别
    // 1.self>title 会修改俩个内容, navigationItem.title 和 tabBatItem.title
    // 2, sef.navigation.title 只修改那navgationBar上的标题
    vc.navigationItem.title = @"来来来";
    vc.title = @"对对对";

    _window.rootViewController = tabBar;
    
    
    
    
    
    
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
